package com.vcredit.creditcat.service.speedloan;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.vcredit.creditcat.model.ProcessSpecialItem;
import com.vcredit.creditcat.persistence.base.ProcessSpecialItemMapper;

/**
 * 
 **/
@Service
public class ProcessSpecialItemService {
	@Autowired
	private ProcessSpecialItemMapper mapper;

	@CacheEvict(key = "'special:processSpecialItems'", value = "processSpecialItem")
	public void insert(ProcessSpecialItem obj) {
		mapper.insert(obj);
	}

	@CacheEvict(key = "'special:processSpecialItems'", value = "processSpecialItem")
	public void update(ProcessSpecialItem obj) {
		mapper.update(obj);
	}

	@Cacheable(key = "'special:processSpecialItems'", value = "processSpecialItem")
	public List<ProcessSpecialItem> findAll() {
		return mapper.findAll();
	}

	private List<ProcessSpecialItem> find(ProcessSpecialItem obj) {
		return mapper.find(obj);
	}

	public List<ProcessSpecialItem> findByProductId(long productId) {
		return mapper.findByProductId(productId);
	}

	@CacheEvict(value = "processSpecialItem",key = "'special:processSpecialItem*'",beforeInvocation=true)
	public void clearProcessSpecialItemsCache() {
		System.out.println("ProcessSpecialItems");
	}
}